package com.chujian.framework.util.mybatis.wrapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.chujian.framework.util.mybatis.MybatisUs;
import lombok.Getter;
import lombok.Setter;

import java.lang.reflect.Field;

@Getter
@Setter
public class WrapperUnit {

    protected QueryWrapper<?> wrapper;
    protected Field field;
    protected Object value;

    protected String col;
    protected String fieldName;

    protected String operate; // 操作

    public WrapperUnit(QueryWrapper<?> wrapper, Field field, Object value) {
        this.wrapper = wrapper;
        this.field = field;
        this.value = value;

        init();
    }

    public WrapperUnit(QueryWrapper<?> wrapper, Field field, Object value, String operate) {
        this.wrapper = wrapper;
        this.field = field;
        this.value = value;
        this.operate = operate;

        init();
    }

    public void init() {
        this.col = MybatisUs.getMyBatisColName(field);
        this.fieldName = field.getName();
    }

}
